package com.edu.mapper;

import com.edu.bean.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 *  @Author:hwy
 *  @Date: 2024/9/20--22:17
 *  @Description:
 */
public interface BookMapper {
    @Select("select * from book where bookId = #{bookId}")
    public Book selectBookById(int bookId);

    @Select("select * from book")
    List<Book> selectAllBooks();

    @Delete("delete from book WHERE bookId = #{bookId}")
    int deleteBook(int bookId);

    @Insert("insert into book(bookName,bookType,bookWriter) VALUES (#{bookName},#{bookType},#{bookWriter})")
    int insertBook(Book book);

    @Update("update book set bookName = #{bookName}, bookType = #{bookType}, bookWriter = #{bookWriter} WHERE bookId = #{bookId}")
    int updateBook(Book book);

}
